package com.sage.commons;

import com.single.commons.ObjectUtils;
import com.single.commons.StringUtils;
import com.single.exceptions.AssertException;

public class AssertUtils {

	
	public static void assertText(String text, String exceptionCode, String message) throws AssertException {
		if(!StringUtils.hasText(text)){
			throw new AssertException(text, exceptionCode, message);
		}
	}
	
	public static void assertText(String text, String message) throws AssertException {
		if(!StringUtils.hasText(text)){
			throw new AssertException(text, message);
		}
	}
	
	public static void assertText(String text, String message, char sep, String... messageParams) throws AssertException {
		if(!StringUtils.hasText(text)){
			throw new AssertException(StringUtils.combine(message, sep, messageParams));
		}
	}
	
	public static void assertText(String text, String exceptionCode, String message, char sep, String... messageParams) throws AssertException {
		if(!StringUtils.hasText(text)){
			throw new AssertException(text, exceptionCode, StringUtils.combine(message, sep, messageParams));
		}
	}
	
	public static void assertNull(Object obj, String message) throws AssertException {
		if(ObjectUtils.isEmpty(obj)){
			throw new AssertException(message);
		}
	}
	
	public static void assertNull(Object obj, String exceptionCode, String message) throws AssertException {
		if(ObjectUtils.isEmpty(obj)){
			throw new AssertException(obj, exceptionCode, message);
		}
	}
	
	public static void assertNull(Object obj, String message, char sep, String... messageParams) throws AssertException {
		if(ObjectUtils.isEmpty(obj)){
			throw new AssertException(StringUtils.combine(message, sep, messageParams));
		}
	}
	
	public static void assertNull(Object obj, String exceptionCode, String message, char sep, String... messageParams) throws AssertException {
		if(ObjectUtils.isEmpty(obj)){
			throw new AssertException(obj, exceptionCode, StringUtils.combine(message, sep, messageParams));
		}
	}
}
